package com.yao.guava_demo.preconditions;

import com.google.common.base.Preconditions;

public class Demo1 {
    public static void main(String[] args) {
//        method1(-1.2);
//        method2(null);
        method3(5);
    }

    public static void method1(double d){
        //检查参数是否符合表达式
        Preconditions.checkArgument(d>0.0,"参数小于等于0");
    }
    public static void method2(Integer a){
        //检查参数是否为空
        Preconditions.checkNotNull(a,"参数为空");
    }
    public static void method3(int i){
        int[] arr={1,2,3};
        //检查下标是否越界
        Preconditions.checkElementIndex(i,arr.length);
    }
}
